#include "pcmaacencodethread.h"
#include <QFile>
#include "ffmepgutils.h"

extern "C" {

    #include <libavcodec/avcodec.h>
    #include <libavutil/avutil.h>
}

PCMAACEncodeThread::PCMAACEncodeThread(QObject *parent) : QThread(parent)
{
    connect(this,&QThread::finished,this,&QThread::deleteLater);
}

PCMAACEncodeThread::~PCMAACEncodeThread()
{
    disconnect();

    requestInterruption();

    quit();
    wait();

    qDebug() << "pcm acc encode thread destroy";
}

void PCMAACEncodeThread::run()
{

    PCMSpec pcmSpec;
    pcmSpec.channelLayout = AV_CH_LAYOUT_STEREO;
    pcmSpec.sampleRate = 48000;
    pcmSpec.sampleFormat = AV_SAMPLE_FMT_S16;
    //pcmSpec.inFilePath  = "/Users/tgy/Documents/ffmpeg/audio/recode_pcm_48000_2_16.pcm";
    //
    pcmSpec.inFilePath  = "/Users/apple/Documents/ffmpeg/qt/audio/recode_pcm_48000_2_16.pcm";
    pcmSpec.outFilePath = "/Users/apple/Documents/ffmpeg/qt/audio/recode_pcm_48000_2_16_code.aac";

    FFMEPGUtils::pcmAACEncode(pcmSpec);

}


